<?php

defined( 'PDNS_AUTH' ) or die( "Unauthorized" );

$domain = $model->domain;
$records = $model->records;
?>

<form method='post'> 
<input type='hidden' name='zone_id' value='<?php echo $domain->id; ?>' />
<input type='hidden' name='section' value='zone' />
<input type='hidden' name='action' value='save' />

<div class='menubar'>
	<input type='submit' name='save' value='Save Changes' />
	<?php /* not implemented
	<input type='submit' name='edit' value='Save Changes and Edit More' />
	*/ ?>
</div>

<p>Domain Name: <input size='50' type='text' name="domain[name]" value='<?php echo $domain->name; ?>' /></p>

<br />Records:
<table class='records-edit'>
<tr>
	<th>Delete</th>
	<th>Name</th>
	<th>Type</th>
	<th>Content</th>
	<th>TTL</th>
	<th>Priority</th>
</tr>
<?php foreach( $records as $r ): ?>
	<tr>
		<!-- Record ID: <?php echo $r->id; ?> -->
		<input type='hidden' name="record[<?php echo $r->id; ?>][id]" value='<?php echo $r->id; ?>' />
		<td class='calign'><input type='checkbox' name="record[<?php echo $r->id; ?>][delete]" value='delete' /></td>
		<td><input class='textbox' type='text' name="record[<?php echo $r->id; ?>][name]" value='<?php echo $r->name; ?>' /></td>
		<td><input class='textbox' size='4' type='text' name="record[<?php echo $r->id; ?>][type]" value='<?php echo $r->type; ?>' /></td>
		<td><input class='textbox' type='text' name="record[<?php echo $r->id; ?>][content]" value='<?php echo $r->content; ?>' /></td>
		<td><input class='textbox' size='10' type='text' name="record[<?php echo $r->id; ?>][ttl]" value='<?php echo $r->ttl; ?>' /></td>
		<td><input class='textbox' size='5' type='text' name="record[<?php echo $r->id; ?>][prio]" value='<?php echo $r->prio; ?>' /></td>
	</tr>
<?php endforeach; ?>
<?php for($i = 0; $i < 3; $i++): ?>
	<tr>
		<!-- New Record  -->
		<input type='hidden' name="newrecord[<?php echo $i;?>][id]" value='' />
		<td class='calign'><input type='checkbox' name="newrecord[<?php echo $i;?>][delete]" value='delete' /></td>
		<td><input class='textbox' type='text' name="newrecord[<?php echo $i;?>][name]" value='' /></td>
		<td><input class='textbox' size='4' type='text' name="newrecord[<?php echo $i;?>][type]" value='' /></td>
		<td><input class='textbox' type='text' name="newrecord[<?php echo $i;?>][content]" value='' /></td>
		<td><input class='textbox' size='10' type='text' name="newrecord[<?php echo $i;?>][ttl]" value='' /></td>
		<td><input class='textbox' size='5' type='text' name="newrecord[<?php echo $i;?>][prio]" value='' /></td>
	</tr>
<?php endfor; ?>
</table>

<p>Records without a Name will be deleted (or not inserted if new).  Save and Edit again to add more records.</p>

<div class='menubar'>
	<input type='submit' name='save' value='Save Changes' />
	<?php /* not implemented
	<input type='submit' name='edit' value='Save Changes and Edit More' />
	*/ ?>
</div>

</form>
